<?php
namespace Home\Controller;
use Think\Controller;
class DataexController extends Controller {
	public function __call($function_name, $args){
        echo json_encode(array());die;
    }
	
	public function cfda_connection(){
		$table = I('get.type','');
		
		if(empty($table)){
			echo json_encode(array('status'=>-1,'msg'=>'请指定查询类型','data'=>null),JSON_UNESCAPED_UNICODE);
			return;
		}
		
        if( !in_array($table, array('choujian','baojianshipin','huazhuangpin','hulianwangfuwu','qixie','wangshangyaodian','yaopin','yaopinguanggao')) ){
        	echo json_encode(array('status'=>-1,'msg'=>'暂不支持该类型','data'=>null),JSON_UNESCAPED_UNICODE);
        	return;
        }
		
		$page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        $name = I('get.name','');
        $company = I('get.company','');
        $sql = "select * from ca_".$table." where 1=1 ";
        
		if(!empty($company)){
			$sql .= " and company like '%".$company."%' ";
		}
		if(!empty($name)){
			$sql.=" and name like '%".$name."%' ";
		}
        
		$sql .= " order by cid ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
	}
   
	public function cfda_search(){
		$this->cfda_connection();
	}
	
	public function ershouche_58(){
		$page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $title = I('get.title','');
        $desc = I('get.desc','');
        $para = I('get.para','');
        $city = I('get.city','bj');
        
        $sql = "select updatetime,mileage,accident,title,price,price_desc,ontime,strong_insurance,yearly_inspection,para,localname,descri,now,emission_standard from ershouche_58 where 1=1 ";
		if(!empty($title)){
			$sql.=" and title like '%".$title."%' ";
		}
		if(!empty($desc)){
			$sql.=" and descri like '%".$desc."%' ";
		}
		if(!empty($para)){
			$sql.=" and para like '%".$para."%' ";
		}		
		if(!empty($city)){
			$sql.=" and localname = '".$city."' ";
		}		
		
	    //价格
        $price = I('get.price','');
        if(!empty($price)){
        	//价格支持按区间查询 区间之间用英文逗号分隔
        	$pu = explode(',',$price); 
        	if(sizeof($pu)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($pu) == 1){
        		if(is_numeric($price)){
        			$sql .= " and SUBSTRING (price, e'(\\\d+(\\\.?\\\d+)?)')::numeric = ".$price." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($pu) == 2){
        		
        		if(is_numeric($pu[0]) && is_numeric($pu[1])){
            		//如果提供了价格区间
            		$sql .= " and SUBSTRING (price, e'(\\\d+(\\\.?\\\d+)?)')::numeric BETWEEN ".$pu[0]." AND ".$pu[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }		
		
	    //行驶公里
        $mileage = I('get.mileage','');
        if(!empty($mileage)){
        	//价格支持按区间查询 区间之间用英文逗号分隔
        	$pu = explode(',',$mileage); 
        	if(sizeof($pu)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'行驶公里区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($pu) == 1){
        		if(is_numeric($mileage)){
        			$sql .= " and SUBSTRING (mileage, e'(\\\d+(\\\.?\\\d+)?)')::numeric = ".$mileage." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'行驶公里格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($pu) == 2){
        		
        		if(is_numeric($pu[0]) && is_numeric($pu[1])){
            		//如果提供了价格区间
            		$sql .= " and SUBSTRING (mileage, e'(\\\d+(\\\.?\\\d+)?)')::numeric BETWEEN ".$pu[0]." AND ".$pu[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'行驶公里区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }			
		
		$sql .= " order by cid ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
	}
	
	public function epneed(){
		
		$page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $name = I('get.name','');
        $desc = I('get.desc','');
        $industry = I('get.industry','');
        
        $sql = "select * from epneed_tourongzishijian where 1=1 ";
		if(!empty($name)){
			$sql.=" and epneed_company_name like '%".$name."%' ";
		}
		if(!empty($desc)){
			$sql.=" and ep_desc like '%".$desc."%' ";
		}
		if(!empty($industry)){
			$sql.=" and epneed_industry like '%".$industry."%' ";
		}		
		
		$sql .= " order by cid ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
		
	}
	
	/**
	 * 企业数据
	 */
	public function company(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $company_name = I('get.company_name','');
        $name = I('get.name','');
        $city = I('get.city','北京');
        
		$sql = "select * from company_200w where 1=1 ";
		
		if(!empty($company_name)){
			$sql .= " and company_name like '%".$company_name."%' ";
		}
		if(!empty($name)){
			$sql.=" and name like '%".$name."%' ";
		}
		if(!empty($city)){
			$sql.=" and loc = '".$city."' ";
		}
		
		$sql .= " order by id ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }
    
	//好大夫在线医院列表
	public function haodf_hospital(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $addr = I('get.addr','');
        $intr = I('get.intr','');
        $name = I('get.name','');
        $tel = I('get.tel','');
        
		$sql = "select * from haodf_hospital_bj where 1=1 ";
		
		if(!empty($addr)){
			$sql.=" and addr like '%".$addr."%' ";
		}
		if(!empty($intr)){
			$sql.=" and intr like '%".$intr."%' ";
		}		
		if(!empty($name)){
			$sql.=" and name like '%".$name."%' ";
		}		
		if(!empty($tel)){
			$sql.=" and tel like '%".$tel."%' ";
		}		
		$sql .= " order by name ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
		
	}
	
	//好大夫在线医生列表
	public function haodf_doctor(){
	       $page = I('get.page',1,'intval');
	        $pagesize = I('get.size',20,'intval');
	        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
                $pagesize = C(AUTH_API_PAGESIZE_MAX);
            }
	        $name = I('get.name','');
	        $jingli = I('get.cv','');
	        $keshi = I('get.department','');
	        $shanchang = I('get.expertise','');
	        $title = I('get.title','');
	        
			$sql = "select * from haodf_doctor_bj where 1=1 ";
			
			if(!empty($name)){
				$sql.=" and name like '%".$name."%' ";
			}
			if(!empty($jingli)){
				$sql.=" and jingli like '%".$jingli."%' ";
			}		
			if(!empty($keshi)){
				$sql.=" and keshi like '%".$keshi."%' ";
			}		
			if(!empty($title)){
				$sql.=" and zhichen like '%".$title."%' ";
			}		
			$sql .= " order by name ";
			$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
			
            // echo $sql;die;
			$pg_connect = $this->conncetPgsql();
	        $result = pg_query($pg_connect,$sql);
	        pg_close($pg_connect);
	        
	        $data = array();
	        while($list = pg_fetch_object($result)){
	            array_push($data, $list);
	        }
	        
	        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);		
	}
	
	public function zhihu(){
	       $page = I('get.page',1,'intval');
	        $pagesize = I('get.size',20,'intval');
	        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
                $pagesize = C(AUTH_API_PAGESIZE_MAX);
            }

	        $name = I('get.name','');
	        $email = I('get.email','');
	        
			$sql = "select * from zhihu where 1=1 ";
			
			if(!empty($addr)){
				$sql.=" and name like '%".$name."%' ";
			}
			if(!empty($intr)){
				$sql.=" and email like '%".$email."%' ";
			}		
			$sql .= " order by name ";
			$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
			$pg_connect = $this->conncetPgsql();
	        $result = pg_query($pg_connect,$sql);
	        pg_close($pg_connect);
	        
	        $data = array();
	        while($list = pg_fetch_object($result)){
	            array_push($data, $list);
	        }
	        
	        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
	}
	
	
	public function company_36kr(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $name = I('get.name',20);
        $introduction = I('get.introduction',20);
        
        $sql = "select * from company_36kr where 1=1 ";
        if(!empty($name)){
        	$sql .= " and (unformal_company_name like '%".$name."%' or formal_company_name like '%".$name."%') ";
        }
        if(empty($introduction)){
        	$sql .= " and introduction like '%".$introduction."%' ";
        }
		
		$sql .= " order by id ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }
	
	public function entinfo(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $company_name = I('get.company_name','');
        $introduction = I('get.introduction','');
        
		$sql = "select * from company_itjuzi where 1=1 ";
		if(!empty($company_name)){
			$sql .= " and company_name like '%".$company_name."%' ";
		}
		if(!empty($introduction)){
			$sql.=" and introduction like '%".$introduction."%' ";
		}
		
		$sql .= "order by id";
		
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

	public function makepolo(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $name = I('get.company_name','');
        $address = I('get.company_address','');
        $main_products = I('get.main_products','');
        
		$sql = "select * from company_makepolo where 1=1 ";
		
		if(!empty($name)){
			$sql .= " and company_name like '%".$name."%' ";
		}
		
		if(!empty($address)){
			$sql .= " and company_address like '%".$address."%' ";
		}
		
		if(!empty($main_products)){
			$sql .= " and company_main_products like '%".$main_products."%' ";
		}
		
		$sql .= " order by company_lianxiren ";
		
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }
    
	
	public function lianjia(){
		
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        //要查询的城市
        $city = I('get.city','bj');
 
        if( !in_array($city, array('bj','gz','sh','sz','cd','hz','nj','tj')) ){
        	echo json_encode(array('status'=>-1,'msg'=>'暂无该城市数据','data'=>null),JSON_UNESCAPED_UNICODE);
        	return;
        }
        
        $table = "lianjia_".$city." t ";
        
        //拼装sql
        $sql = "select * from ".$table." where 1=1 ";
        
        //区域
        $area = I('get.area','');
        if(!empty($area)){
        	$sql.= " and t.area like '%".$area."%' ";
        }        
        
		//朝向
        $direction = I('get.direction','');
        if(!empty($direction)){
        	$sql.= " and t.direction like '%".$direction."%' ";
        } 
        
        //小区名
        $community = I('get.community','');
        if(!empty($community)){
        	$sql.= " and t.community like '%".$community."%' ";
        } 
        
        //楼层
        $floor = I('get.floor','');
        if(!empty($floor)){
        	if(is_numeric($floor)){
        		$sql .="and SUBSTRING (t.floor, e'(\\\d+)')::NUMERIC=".$floor." ";
        	}else{
        		echo json_encode(array('status'=>-2,'msg'=>'楼层只能是数字','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        }
        
        //居室
        $layout = I('get.layout','');
        if(!empty($layout)){
        	if(is_numeric($layout)){
        		$sql .="AND SUBSTRING (T.layout, e'(\\\d*).*室') :: int = ".$layout." ";
        	}else{
        		echo json_encode(array('status'=>-3,'msg'=>'居室只能是数字','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        }
        
        //价格
        $price = I('get.price_total','');
        if(!empty($price)){
        	//价格支持按区间查询 区间之间用英文逗号分隔
        	$ps = explode(',',$price); 
        	if(sizeof($ps)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($ps) == 1){
        		if(is_numeric($price)){
        			$sql .= " and SUBSTRING (t.price_total, e'(\\\d*\.?\\\d*)')::NUMERIC = ".$price." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($ps) == 2){
        		
        		if(is_numeric($ps[0]) && is_numeric($ps[1])){
            		//如果提供了价格区间
            		$sql .= " and SUBSTRING (t.price_total, e'(\\\d*\.?\\\d*)')::NUMERIC BETWEEN ".$ps[0]." AND ".$ps[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }
        
        //单价
        $unit = I('get.unit','');
        if(!empty($unit)){
        	//价格支持按区间查询 区间之间用英文逗号分隔
        	$pu = explode(',',$unit); 
        	if(sizeof($pu)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($pu) == 1){
        		if(is_numeric($unit)){
        			$sql .= " and substring(t.price_unit,'\\\d+')::NUMERIC = ".$unit." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($pu) == 2){
        		
        		if(is_numeric($pu[0]) && is_numeric($pu[1])){
            		//如果提供了价格区间
            		$sql .= " and substring(t.price_unit,'\\\d+')::NUMERIC BETWEEN ".$pu[0]." AND ".$pu[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }
        
        //平米
        $space = I('get.space','');
        if(!empty($space)){
        	
           	//平米支持按区间查询 区间之间用英文逗号分隔
        	$pe = explode(',',$space); 
        	if(sizeof($pe)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'平米区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($pe) == 1){
        		if(is_numeric($space)){
        			$sql .= "and  SUBSTRING (t.space, e'(\\\d*\.?\\\d*)')::NUMERIC= ".$space." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($pe) == 2){
        		
        		if(is_numeric($pu[0]) && is_numeric($pu[1])){
            		//如果提供了平米区间
            		$sql .= " and SUBSTRING (t.space, e'(\\\d*\.?\\\d*)')::NUMERIC BETWEEN ".$pe[0]." AND ".$pe[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'平米区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }
        
        $sql .= " order by t.now desc";
        
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
        
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
	}
	
	public function lianjia_chengjiao(){
		
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        //要查询的城市
        $city = I('get.city','bj');
 
        if( !in_array($city, array('bj','gz','sh','sz','cd','hz','nj','tj')) ){
        	echo json_encode(array('status'=>-1,'msg'=>'暂无该城市数据','data'=>null),JSON_UNESCAPED_UNICODE);
        	return;
        }
        
        $table = "chengjiao_".$city." t ";
        
        //拼装sql
        $sql = "select * from ".$table." where 1=1 ";
        
        //区域
        $area = I('get.area','');
        if(!empty($area)){
        	$sql.= " and t.area like '%".$area."%' ";
        }        
        
		//朝向
        $direction = I('get.direction','');
        if(!empty($direction)){
        	$sql.= " and t.direction like '%".$direction."%' ";
        } 
        
        //小区名
        $community = I('get.community','');
        if(!empty($community)){
        	$sql.= " and t.community like '%".$community."%' ";
        } 
        
        //楼层
        $floor = I('get.floor','');
        if(!empty($floor)){
        	if(is_numeric($floor)){
        		$sql .="and SUBSTRING (t.floor, e'(\\\d+)')::NUMERIC=".$floor." ";
        	}else{
        		echo json_encode(array('status'=>-2,'msg'=>'楼层只能是数字','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        }
        
        //居室
        $layout = I('get.layout','');
        if(!empty($layout)){
        	if(is_numeric($layout)){
        		$sql .="AND SUBSTRING (T.layout, e'(\\\d*).*室') :: int = ".$layout." ";
        	}else{
        		echo json_encode(array('status'=>-3,'msg'=>'居室只能是数字','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        }
        
        //价格
        $price = I('get.price_total','');
        if(!empty($price)){
        	//价格支持按区间查询 区间之间用英文逗号分隔
        	$ps = explode(',',$price); 
        	if(sizeof($ps)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($ps) == 1){
        		if(is_numeric($price)){
        			$sql .= " and SUBSTRING (t.price_total, e'(\\\d*\.?\\\d*)')::NUMERIC = ".$price." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($ps) == 2){
        		
        		if(is_numeric($ps[0]) && is_numeric($ps[1])){
            		//如果提供了价格区间
            		$sql .= " and SUBSTRING (t.price_total, e'(\\\d*\.?\\\d*)')::NUMERIC BETWEEN ".$ps[0]." AND ".$ps[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }
        
        //单价
        $unit = I('get.unit','');
        if(!empty($unit)){
        	//价格支持按区间查询 区间之间用英文逗号分隔
        	$pu = explode(',',$unit); 
        	if(sizeof($pu)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($pu) == 1){
        		if(is_numeric($unit)){
        			$sql .= " and substring(t.price_unit,'\\\d+')::NUMERIC = ".$unit." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($pu) == 2){
        		
        		if(is_numeric($pu[0]) && is_numeric($pu[1])){
            		//如果提供了价格区间
            		$sql .= " and substring(t.price_unit,'\\\d+')::NUMERIC BETWEEN ".$pu[0]." AND ".$pu[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        	
        }
        
        //平米
        $space = I('get.space','');
        if(!empty($space)){
        	
           	//平米支持按区间查询 区间之间用英文逗号分隔
        	$pe = explode(',',$space); 
        	if(sizeof($pe)>2){
        		echo json_encode(array('status'=>-4,'msg'=>'平米区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
        		return;
        	}
        	//如果仅传入了一个值
        	if(sizeof($pe) == 1){
        		if(is_numeric($space)){
        			$sql .= "and  SUBSTRING (t.space, e'(\\\d*\.?\\\d*)')::NUMERIC= ".$space." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}else if(sizeof($pe) == 2){
        		
        		if(is_numeric($pu[0]) && is_numeric($pu[1])){
            		//如果提供了平米区间
            		$sql .= " and SUBSTRING (t.space, e'(\\\d*\.?\\\d*)')::NUMERIC BETWEEN ".$pe[0]." AND ".$pe[1]." ";
        		}else{
        			echo json_encode(array('status'=>-4,'msg'=>'平米区间格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
        			return;
        		}
        	}
        }
        
        $sql .= " order by t.now desc";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
        
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
	}
	
	//下厨房，豆果网
	public function caipu(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.pagesize',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $name = I('get.name',null);
        $category = I('get.category',null);

        $sql = "select description,name,recipe_type as recipe,step from caipu where 1=1 ";
        if(!empty($name)){
            $sql .= " and name like '%".$name."%' ";
        }
        if(!empty($category)){
            $sql .= " and recipe_type like '%".$category."%' ";   
        }

        $sql .= " order by cid desc";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            $step = json_decode($list->step);
            ksort($step);
            $list->step = $step;
            array_push($data, $list);
        }
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }
    
    //学校相关查询
    public function school(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.pagesize',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        $name = I('get.name',null);//学校名称
        $type = I('get.type',null);//学校类型
        $address = I('get.address',null);//学校地址

        $sql = "select addr as address,school_name as name,type,introduction,bus_routes from school_info where 1=1 ";
        if(!empty($name)){
            $sql .= " and school_name like '%".$name."%' ";
        }
        if(!empty($type)){
            $sql .= " and type like '%".$type."%' ";   
        }
        
        if(!empty($address)){
            $sql .= " and addr like '%".$address."%' ";
        }
        $sql .= " order by cid desc";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }
    
    //百度招聘
    public  function jobs(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.pagesize',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        //城市
        $city = I('get.city',null);
        //区
        $district = I('get.district',null);
        //学历要求
        $educaton = I('get.educaton',null);

        //开始日期，结束日期

        $sql = "select city,company_address,description,educaton,startdate,enddate,experience,number,official_name as name,ori_district as district,ori_salary as salary,title,source_url from baidu_jobs where 1=1 ";
        if(!empty($city)){
            $sql .= " and city like '%".$city."%' ";
        }
        if(!empty($district)){
            $sql .= " and ori_district like '%".$district."%' ";   
        }
        if(!empty($educaton)){
            $sql .= " and educaton = '".$educaton."' ";   
        }

        $sql .= " order by cid desc";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);

    }

    //微信公众号
    public function wxsubscription(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.pagesize',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        //昵称
        $name = I('get.name',null);
        //微信号
        $code = I('get.code',null);

        $sql = "select wx_account as code,wx_name as name,label,type,fans_count,description,avg_click_count,avg_like_count from weixin_subscription where 1=1 ";
        if(!empty($name)){
            $sql .= " and wx_name like '%".$name."%' ";
        }
        if(!empty($code)){
            $sql .= " and wx_account='".$code."' ";   
        }

        $sql .= " order by cid desc";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);

    }

    //户外店铺
    public function outdoorshop(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.pagesize',20,'intval');
        if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
            $pagesize = C(AUTH_API_PAGESIZE_MAX);
        }

        //名称
        $name = I('get.name',null);
        //地址
        $address = I('get.address',null);

        $sql = "select address,introduction,name,reviews_count,tel,url,score from sport_8264 where 1=1 ";
        if(!empty($name)){
            $sql .= " and name like '%".$name."%' ";
        }
        if(!empty($address)){
            $sql .= " and address like '%".$address."%' ";   
        }

        $sql .= " order by cid desc";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE); 
    }

    //拉勾网-公司职位
    public function lagou_company_job(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');

        $company_name = I('get.company','');

        $sql = "select job.job_title,job.job_request,job.city,job.publish_time,to_char(job.now, 'YYYY-MM-DD') now,ent.type,ent.number,ent.process,ent.company from lagou_company ent join lagou_job job on ent.companyid=job.companyid ";

        if(!empty($company_name)){
                $sql .= " and ent.company like '%".$company_name."%' ";
        }

        $sql .= " order by job.cid ";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;


        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    //拉钩企业
    public function lagou_company(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');

        $company_name = I('get.company','');
        $city = I('get.city','');

        $sql = "select city,manager_list,addr,type,company,area,number,process,intro,product_list from lagou_company where 1=1 ";

        if(!empty($company_name)){
                $sql .= " and company like '%".$company_name."%' ";
        }

        if(!empty($city)){
                $sql.=" and city = '".$city."' ";
        }

        $sql .= " order by cid ";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;

        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    //拉钩工作
    public function lagou_job(){

        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');

        $title = I('get.title','');
        $city = I('get.city','');

        $sql = "select job.city,job.job_desc,job.job_title,job.job_request,job.publish_time,to_char(job.now, 'YYYY-MM-DD') now,ent.type,ent.number,ent.process,ent.company from lagou_job job join lagou_company ent on job.companyid=ent.companyid where 1=1 ";

        if(!empty($title)){
                $sql.=" and job.job_title like '%".$title."%' ";
        }
        if(!empty($city)){
                $sql.=" and job.city = '".$city."' ";
        }

        $sql .= " order by job.cid ";
        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;


        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    //外卖平台
    public function waimai_store(){

        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');


        //拼装sql
        $sql = "select restrunt_name as name,restrunt_addr as addr,restrunt_sale as sale_number from waimai where 1=1 ";

        //外卖店铺名称
        $name = I('get.name','');
        if(!empty($name)){
                $sql.= " and restrunt_name like '%".$name."%' ";
        }

        $sql .= " order by cid";

        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;

        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }


    public function market_calendar(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        $name = I('get.name','');
        $code = I('get.code','');

        $sql = "select code,event_type,description,stock_type,name,to_char(date, 'YYYY-MM-DD') date from stock_market_calendar where 1=1 ";

        if(!empty($name)){
                $sql .= " and name like '%".$name."%' ";
        }

        if(!empty($code)){
                $sql .= " and code = '".$code."' ";
        }

        $date = I('get.date','');
        if(!empty($date)){
            //日期支持按区间查询 区间之间用英文逗号分隔
            $pu = explode(',',$date);
            if(sizeof($pu)>2){
                    echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
                    return;
            }
            //如果仅传入了一个值
            if(sizeof($pu) != 2){
                    echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
                    return;
            }else if(sizeof($pu) == 2){

                    //if(is_numeric($pu[0]) && is_numeric($pu[1])){
                    //如果提供了价格区间
                    //$sql .= " and SUBSTRING (price, e'(\\\d+(\\\.?\\\d+)?)')::numeric BETWEEN ".$pu[0]." AND ".$pu[1]." ";

            $sql .= " and date between to_date('".$pu[0]."', 'YYYY-MM-DD') and to_date('".$pu[1]."', 'YYYY-MM-DD') ";

            }
        }

        $sql .= " order by cid ";

        $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
        $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    // 证监信息公开
    public function neeq_supervise(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');

        $title = I('get.title','');
        $company_name = I('get.company_name','');

                $sql = "select title,code,company_name,publish_time,url from equities_exchange_regulatory where 1=1 ";

                if(!empty($title)){
                        $sql.=" and title like '%".$title."%' ";
                }
                if(!empty($company_name)){
                        $sql.=" and company_name like '%".$company_name."%' ";
                }

                $sql .= " order by cid ";
                $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
                $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);

    }

    //审查信息公开
    public function neeq_examine(){
           $page = I('get.page',1,'intval');
            $pagesize = I('get.size',20,'intval');

            $title = I('get.title','');

            $sql = "select title,publish_time,url from equities_exchange_review where 1=1  ";

            if(!empty($title)){
                    $sql.=" and title like '%".$title."%' ";
            }

            $sql .= " order by cid ";
            $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;

            $pg_connect = $this->conncetPgsql();
            $result = pg_query($pg_connect,$sql);
            pg_close($pg_connect);

            $data = array();
            while($list = pg_fetch_object($result)){
                array_push($data, $list);
            }

            echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    // datasum/neeq/dpublicabnormalinfo
    public function neeq_transinfo(){
           $page = I('get.page',1,'intval');
            $pagesize = I('get.size',20,'intval');

            $securities_code = I('get.securities_code','');
            $securities_name = I('get.securities_name','');
            $buyer = I('get.buyer','');
            $buyer_depart = I('get.buyer_depart','');
            $seller = I('get.seller','');
            $seller_depart = I('get.seller_depart','');

            $sql = "select buyer,buyer_department,date,securities_code,securities_count,securities_name,securities_price,seller,seller_department,to_char(date, 'YYYY-MM-DD') date from equities_transfer_list where 1=1 ";

            if(!empty($securities_code)){
                    $sql.=" and securities_code = '".$securities_code."' ";
            }

            if(!empty($securities_name)){
                    $sql.=" and securities_name like '%".$securities_name."%' ";
            }

            if(!empty($buyer)){
                    $sql.=" and buyer like '%".$buyer."%' ";
            }

            if(!empty($buyer_depart)){
                    $sql.=" and buyer_department like '%".$buyer_depart."%' ";
            }
            if(!empty($seller)){
                    $sql.=" and seller like '%".$seller."%' ";
            }

            if(!empty($seller_depart)){
                    $sql.=" and seller_department like '%".$seller_depart."%' ";
            }

            $date = I('get.date','');
            if(!empty($date)){
                //日期支持按区间查询 区间之间用英文逗号分隔
                $pu = explode(',',$date);
                if(sizeof($pu)>2){
                        echo json_encode(array('status'=>-4,'msg'=>'价格区间最多支持俩参数','data'=>null),JSON_UNESCAPED_UNICODE);
                        return;
                }
                //如果仅传入了一个值
                if(sizeof($pu) != 2){
                        echo json_encode(array('status'=>-4,'msg'=>'价格格式错误','data'=>null),JSON_UNESCAPED_UNICODE);
                        return;
                }else if(sizeof($pu) == 2){

                        //if(is_numeric($pu[0]) && is_numeric($pu[1])){
                        //如果提供了价格区间
                        //$sql .= " and SUBSTRING (price, e'(\\\d+(\\\.?\\\d+)?)')::numeric BETWEEN ".$pu[0]." AND ".$pu[1]." ";
                    $sql .= " and date between to_date('".$pu[0]."', 'YYYY-MM-DD') and to_date('".$pu[1]."', 'YYYY-MM-DD') ";
                }
            }




            $sql .= " order by cid ";
            $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
            $pg_connect = $this->conncetPgsql();
            $result = pg_query($pg_connect,$sql);
            pg_close($pg_connect);

            $data = array();
            while($list = pg_fetch_object($result)){
                array_push($data, $list);
            }

            echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    //挂牌公司列表
    public function neeq_listingNew(){
        $page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');

        $name = I('get.name','');
        $code = I('get.code','');

        $sql = "select announcement_url,detail_url,code,industry,type,short_name from equities_company_list where 1=1 ";
        if(!empty($name)){
                $sql .= " and short_name like '%".$name."%' ";
        }
        if(!empty($code)){
                $sql .= " and code = '".$code."' ";
        }

                $sql .= " order by cid ";
                $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
                $pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);

        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }

        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
    }

    //所有新生成api，入口---http://www.dataex.com/api/tablename/service/api?name=ty&sex=man
    public function api(){
        //获取-服务名-api名，参数
        // echo "<pre>";print_r($_GET);
        $data = array('status'=>1001,'msg'=>'无效请求','data'=>null);

        $params = $_GET;
        extract($_GET);
        // echo "<pre>";print_r($_GET);die;
        if(isset($tablename) && $tablename){
            if(isset($service) && isset($api) && $service && $api){
                //获取api信息
                $api_info = $this->getApiInfo( trim($service), trim($api) );

                if(empty($api_info)){
                    echo json_encode(array('status'=>0,'msg'=>'ok','data'=>null),JSON_UNESCAPED_UNICODE);exit;
                }
                // echo "<pre>";print_r($api_info);

                //返回信息
                $field_array = json_decode($api_info['api_result_field'],true);
                $field_string = "";
                if(empty($field_array)){
                    $field_string = "*";    
                }else{
                    $return_field_array = array();
                    foreach ($field_array as $k=>$v){
                        array_push($return_field_array, $v['name']);
                    }                    
                    $field_string = implode(",", $return_field_array);
                }
                // echo $field_string."===";
                // echo "<pre>";print_r($field_array);die;
                //请求条件--暂时不需要过滤

                $page = I('get.page',1,'intval');
                $pagesize = I('get.size',20,'intval');
                if($pagesize > C(AUTH_API_PAGESIZE_MAX)){
                    $pagesize = C(AUTH_API_PAGESIZE_MAX);
                }

                //组织sql查询语句
                unset($params['tablename'],$params['service'],$params['api'],$params['page'],$params['size']);
               $sql = "select ".$field_string." from ".trim($tablename)." where 1=1 ";
               foreach ($params as $field=>$value){
                    if(!empty($value)){
                        $sql .= " and ".$field."='".$value."' ";   
                    }
                }
                $sql .= " order by cid desc";
                $sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize;
                // echo $sql;die;
                
                $pg_connect = $this->conncetPgsql();
                try{
                    $result = pg_query($pg_connect,$sql);
                    pg_close($pg_connect);

                    $data = array();
                    while($list = pg_fetch_object($result)){
                        array_push($data, $list);
                    }
                    echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
                }catch(exception $e){
                    pg_close($pg_connect);
                    echo json_encode(array('status'=>1003,'msg'=>'服务请求不能被识别','data'=>null));exit();
                }
                
            }else{
                echo json_encode($data);exit();
            }
        }else{
            echo json_encode($data);exit();
        }
    }

    //封装第三方接口请求(http://www.dataex.com/app/fangjiang/gujia?test=111)---服务名，api名，url，
    public function app(){
        //获取原始url及参数信息
        $params = $_GET;
        extract($_GET);
        timp($params);die;
        //增添账号密钥信息

        //向第三方发送请求


    }

    //链接pgsql(dataex爬虫数据)
    protected function conncetPgsql(){
        $conn_string  =  "host=".C(DATAEXGP_HOST)." port=".C(DATAEXGP_PORT)." dbname=".C(DATAEXGP_DB_NAME)." user=".C(DATAEXGP_DB_USER)." password=".C(DATAEXGP_DB_PWD); 
        $dbconn = pg_connect($conn_string);
        
        if ($dbconn){
            return $dbconn;
        } else {
            pg_close($dbconn);
            $this->error('链接pg库失败');
        }
    } 
    
    private function getApiInfo($service = null, $api = null){
        if(empty($service) || empty($api)) return null;

        $apiModel = M('ServiceApisImage');
        $where['service_name_en'] = $service;
        $where['api_name_en'] = $api;
        $info = $apiModel->where($where)->find();

        return $info;
    }

}